package metalink.admin;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
import java.sql.*;
import vo.*;
import vo.mixed.*;
import model.admin.*;
import myutil.*;


public class QueryBuilderLookUp extends ActionSupport{
	private String lookup_entry;//coming from query builder form
	
HashMap<String,String> hm_tables=new HashMap<String,String>();// stores key value pairs containing original table names and displayed table names
private ArrayList<String> keys=new ArrayList<String>(); //column names for given table name

	public String execute(){
		try{
			 hm_tables.put("Batch","batch_details");
	            hm_tables.put("Course","course_details");
	            hm_tables.put("Department","department_details");
	            hm_tables.put("Student","student_details");
	            hm_tables.put("Hostel","college_residential");
	            hm_tables.put("Library","library_book_details");
	            hm_tables.put("Placement","placements");
	            hm_tables.put("Degree","degree_details");
	            hm_tables.put("Staff","college_staff");
	            String table_name=hm_tables.get(lookup_entry);
	            Connect c=new Connect();
	            ResultSet rs=c.getResult("desc "+table_name);
	        
	          
	            while(rs.next()){
	            	keys.add(rs.getString("Field"));
	            	
	            	
	            }
	           
	            
	            return SUCCESS;
			
			
			
			
		}catch(Exception e){
			e.printStackTrace();
			return ERROR;
		}
           
            
	}

	public String getLookup_entry() {
		return lookup_entry;
	}

	public void setLookup_entry(String lookup_entry) {
		this.lookup_entry = lookup_entry;
	}

	public ArrayList<String> getKeys() {
		return keys;
	}

	public void setKeys(ArrayList<String> keys) {
		this.keys = keys;
	}

	
}
